﻿
function doSearchA()
{   
		var con_item_3 = document.getElementById("item_3").value;
		var con_topicwords = document.getElementById("topicwords").value;
	   	var con_item_9=document.getElementById("item_9").value;
        var con_cocreator=document.getElementById("cocreator").value;

        var con_startyear=document.getElementById("startyear").options[document.getElementById("startyear").options.selectedIndex].value;
    	var con_endyear=document.getElementById("endyear").options[document.getElementById("endyear").options.selectedIndex].value;
         
         

        var con_pronvince=document.getElementById("province").options[document.getElementById("province").options.selectedIndex].value;
        var con_pronvince_c=document.getElementById("province").options[document.getElementById("province").options.selectedIndex].text;

        //var con_item_2 = document.all.item_2.options[document.all.item_2.options.selectedIndex].value;
        //var con_item_2_c = document.all.item_2.options[document.all.item_2.options.selectedIndex].text;

        //var con_item_16 = document.all.item_16.options[document.all.item_16.options.selectedIndex].value;
       // var con_item_16_c = document.all.item_16.options[document.all.item_16.options.selectedIndex].text;

        //var con_item_126=document.all.item_126_net.options[document.all.item_126_net.options.selectedIndex].value;
        //var con_item_126_c=document.all.item_126_net.options[document.all.item_126_net.options.selectedIndex].text;

		
        //var con_source = document.all.source.options[document.all.source.options.selectedIndex].value;
        //var con_source_c = document.all.source.options[document.all.source.options.selectedIndex].text;
        
        var con_NewEnergyClass = document.getElementById("NewEnergyClass").options[document.getElementById("NewEnergyClass").selectedIndex].value;
        var con_NewEnergyClass_c = document.getElementById("NewEnergyClass").options[document.getElementById("NewEnergyClass").selectedIndex].text;
              
        /*仅限可转让项目
        if (document.all.item_32.checked == true) {
            var con_item_32="1";
        }  
        else {
            var con_item_32="";
        } 
        */
       
        //var con_item_12=document.all.item_12.value;
 
        if (con_startyear == "1978") {
           con_startyear="";
        }

       if (con_endyear == "2010") {
             con_endyear="";
             
       }
       
       //&& con_item_12 == "" && con_item_32 == "" && con_source == "" && con_item_126 && con_item_16 == "" && con_item_2 == ""
       if (con_topicwords == ""    && con_startyear == "" && con_endyear == ""    && con_item_9 == ""   == "" && con_cocreator == "" &&  con_pronvince == ""  && con_NewEnergyClass == "" && con_item_3 == "")
      {
        alert("请选择检索字段，谢谢！");
        return;
       }

      
    document.getElementById("topicname").value = "";
    var v_condition = " 1=1 ";
    //标题
    if  (con_item_3 != "")
    {  	v_condition = v_condition + " and (Kjcg_Item_3 like '%" + con_item_3 + "%' )"  ;
        document.getElementById("topicname").value = con_item_3;
    }
  
     //检索词          
    if  (con_topicwords!="")
    {  
        if (con_topicwords.indexOf(" ") != "-1") {
           var topics =new Array();
           topics = con_topicwords.split(" ");
           var i;
           var KeywordS;
           for(i=0;i<topics.length;i++) {
              if (i==0) 
                KeywordS = " KjcgID in (select KjcgID from T_KjcgKey where Keyword = '"+ topics[i] +"')";
              else
                KeywordS = KeywordS + " and KjcgID in (select KjcgID from T_KjcgKey where Keyword = '"+ topics[i] +"')";
           }
           v_condition = v_condition + " and " +KeywordS ;  
        }
        else {
           v_condition=v_condition+" and (KjcgID in (select KjcgID from T_KjcgKey where Keyword = '"+con_topicwords+"'))"  ;
        }
    	//v_condition=v_condition+" and (TopicWords like '%"+con_topicwords+"%'" + " or  Kjcg_Item_3 like '%"+con_topicwords+"%')"  ;
       // v_condition=v_condition+" and (KjcgID in (select KjcgID from T_KjcgKey where Keyword = '"+con_topicwords+"'))"  ;
        document.getElementById("topicname").value = con_topicwords;
     } 
    
    //中图分类代码          
    /*if (con_item_12!="")
    {   if (document.all.topicname.value == "") {
                        document.all.topicname.value = con_item_12;
        }
        else {
                        document.all.topicname.value = document.all.topicname.value + "+" +con_item_12;
        }   
		con_item_12 = con_item_12.split("(")[1];
		con_item_12 = con_item_12.substring(0, con_item_12.length-1);
    	v_condition=v_condition + " and Kjcg_Item_12 like '"+con_item_12+"%'";
    }*/

    //年份
     if  (con_startyear > con_endyear && con_endyear !="") 
     { 
     	alert("年份选择有误,请重新选择!");
      	return;
     }
                
    if  (con_startyear!="")
    {
    	v_condition=v_condition+" and Kjcg_Item_Year>='"+con_startyear+"'" ;
                if (document.getElementById("topicname").value == "") {
                        document.getElementById("topicname").value = "自"+con_startyear+"年";
                }
                else {
                        document.getElementById("topicname").value = document.getElementById("topicname").value + "+" + "自"+con_startyear+"年";
                }  
    } 
  
    if (con_endyear!="")
    {
    	v_condition=v_condition+" and  Kjcg_Item_Year<='"+con_endyear+"'";
                if (document.getElementById("topicname").value == "") {
                        document.getElementById("topicname").value = "至"+con_endyear+"年";
                }
                else {
                        document.getElementById("topicname").value = document.getElementById("topicname").value +"+至"+con_endyear+"年";     
                }  
    }
 
    

    //成果水平          
    /*if (con_item_2!="")
    {
    	v_condition=v_condition+" and Kjcg_Item_2='"+con_item_2+"'";
        if (document.all.topicname.value == "") {
                        document.all.topicname.value = con_item_2_c;
        }
        else {
                        document.all.topicname.value = document.all.topicname.value + "+" +con_item_2_c;
        }
    }   */

    //采集渠道
    /*if (con_source=="1")
    {
    	v_condition=v_condition+" and substring(AchiveType,1,1)='1'";
        if (document.all.topicname.value == "") {
                        document.all.topicname.value = con_source_c;
        }
        else {
                        document.all.topicname.value = document.all.topicname.value + "+" +con_source_c;
        }
    } */
   
    //是否可转让         
    /*if  (con_item_32 == "1")
    {
    	v_condition=v_condition+" and Kjcg_Item_33 <> '3'" ;
        if (document.all.topicname.value == "") {
                        document.all.topicname.value = "仅限可转让项目";
        }
        else {
                        document.all.topicname.value = document.all.topicname.value + "+" +"仅限可转让项目";
        }
   
    }*/

    //所属科技计划       
   /*if  (con_item_126 != "")
   {   switch(con_item_126) {
       case "1" :
           v_condition=v_condition + " and Kjcg_Item_140='1'";
           break;
       case "2" :      
           v_condition=v_condition + " and (Kjcg_Item_140='7' or Kjcg_Item_140='2') ";
           break;
       case "3" :      
           v_condition=v_condition + " and Kjcg_Item_140='3' ";
           break;
       case "4" :      
           v_condition=v_condition + " and Kjcg_Item_126='01'and (Kjcg_Item_140='9' or Kjcg_Item_140='8' or Kjcg_Item_140='4' or Kjcg_Item_140='5' or Kjcg_Item_140='6')";
           break;
       case "5" :
           v_condition=v_condition + " and Kjcg_Item_126='02'";
           break;
       case "6" :
           v_condition=v_condition + " and Kjcg_Item_126='03'";
           break;
       }
     	
        if (document.all.topicname.value == "") {
                        document.all.topicname.value = con_item_126_c;
        }
        else {
                        document.all.topicname.value = document.all.topicname.value + "+" +con_item_126_c;
        }
    }*/



     //所处阶段          
    /*if (con_item_16 != "")
    {
    	v_condition=v_condition+" and Kjcg_Item_16='"+con_item_16+"'";
        if (document.all.topicname.value == "") {
                        document.all.topicname.value = con_item_16_c;
        }
        else {
                        document.all.topicname.value = document.all.topicname.value + "+" +con_item_16_c;
        }
    }*/
 
      //完成单位          
    if  (con_item_9!="")
    {
    	v_condition=v_condition+" and Kjcg_Item_9 like '%"+con_item_9+"%'" ;
        if (document.getElementById("topicname").value == "") {
              document.getElementById("topicname").value = con_item_9;
        }
        else {
             document.getElementById("topicname").value = document.getElementById("topicname").value + "+" +con_item_9;
        }
    } 

     //完成人            
   if  (con_cocreator!="")
    {
    	v_condition=v_condition+" and CoCreator like'%"+con_cocreator+"%'" ;
        if (document.getElementById("topicname").value == "") {
                        document.getElementById("topicname").value = con_cocreator;
        }
        else {
                        document.getElementById("topicname").value = document.getElementById("topicname").value + "+" +con_cocreator;
        }
        
    } 

    //省市          
    if (con_pronvince != "")
    {
    	v_condition=v_condition+" and Kjcg_Item_dqdm='"+con_pronvince+"'";
        if (document.getElementById("topicname").value == "") {
                        document.getElementById("topicname").value = con_pronvince_c;
        }
        else {
                        document.getElementById("topicname").value = document.getElementById("topicname").value + "+" +con_pronvince_c;
        }
    }
    
    //项目类别
     if (con_NewEnergyClass != "")
    {  
    	if(con_NewEnergyClass.indexOf(".")!=-1){
    		v_condition=v_condition+" and (NewEnergyClass1='" + con_NewEnergyClass.split(".")[0] + "' and NewEnergyClass2='" + con_NewEnergyClass.split(".")[1] + "')";
    	}else{
    		v_condition=v_condition+" and (NewEnergyClass1='" + con_NewEnergyClass + "')";
    	}
        
        if (document.getElementById("topicname").value == "") {
               document.getElementById("topicname").value = con_NewEnergyClass_c;
        }
        else {
                document.getElementById("topicname").value = document.getElementById("topicname").value + "+" + con_NewEnergyClass_c;
        }
    }
    document.getElementById("key").value=v_condition;
    document.getElementById("searchform").submit();

}


function doSearch()
{      var con_item_3 = document.getElementById("item_3").value;
       
       if (con_item_3 == "" )
      {
        alert("请选择检索词，谢谢！");
        return;
       }
     
      var v_condition = " 1=1 ";
      var v_condition1 = "";
      var v_condition2 = ""; 
      document.getElementById("topicname").value = con_item_3;  
   
      //标题
    if  (con_item_3 != "")
    {  	v_condition1 = "( Kjcg_Item_3 like '%" + con_item_3 + "%' or  Kjcg_Item_9 like '%" +  con_item_3 + "%'" + " or Kjcg_Item_13_1 like '%" + con_item_3 + "%')";
        
    }
     
     //检索词          
    if  (con_item_3!="")
    {  
        if (con_item_3.indexOf(" ") != "-1") {
           var topics =new Array();
           topics = con_item_3.split(" ");
           var i;
           var KeywordS;
           for(i=0;i<topics.length;i++) {
              if (i==0) 
                  KeywordS = " KjcgID in (select KjcgID from T_KjcgKey where Keyword = '"+ topics[i] +"')";
              else
                  KeywordS = KeywordS + " and KjcgID in (select KjcgID from T_KjcgKey where Keyword = '"+ topics[i] +"')";
           }
           v_condition2 = KeywordS ;  
        }
        else {
           v_condition2 =  "(KjcgID in (select KjcgID from T_KjcgKey where Keyword = '"+con_item_3+"'))"  ;
        }
       
     } 
     
        
      
     
     if  (con_item_3!="")
       v_condition =  v_condition1 + " or " + v_condition2 ;
       
       document.getElementById("key").value=v_condition;
    document.getElementById("searchform").submit(); 
   
}




function changeOption(v_value,v_text,v_option)
{   
    document.getElementById(v_option).options[document.getElementById(v_option).selectedIndex].value=v_value;
    document.getElementById(v_option).options[document.getElementById(v_option).selectedIndex].text=v_text; 
    
}




